﻿using builderDesignMode.Configuration.Provider;

namespace builderDesignMode.Configuration
{
    public class Configuration
    {
        /// <summary>
        /// 配置数据  分别存储 违背开闭原则
        /// </summary>
        /*public IDictionary<string, string> jsonData {get; } = new Dictionary<string, string>();

        public IDictionary<string, string> xmlData { get; } = new Dictionary<string, string>();*/
        /*public List<IDictionary<string, string>> Datss { get; } = new List<IDictionary<string, string>>();

        public JsonConfigurationProvider jsonConfigurationProvider = new JsonConfigurationProvider();

        public XmlConfigurationProvider xmlConfigurationProvider = new XmlConfigurationProvider();*/

        public List<IDictionary<string, object>> Datss { get; } = new List<IDictionary<string, object>>();

        public List<IxConfigurationProvider> configurationProviders = new List<IxConfigurationProvider>();

        public Configuration()
        {

        }

        public string this[string key]
        {
            get {
                foreach (var item in configurationProviders) 
                {
                    if (item.Get(key) != null)
                        return item.Get(key);
                    else
                        return null;
                }
                return null;
            }
        }
    }
}
